<?php
session_start();
$page_title = '访问被拒绝 - 考务管理系统';
?>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $page_title; ?></title>
    <link rel="stylesheet" href="css/style.css">
</head>
<body>
    <div class="error-container">
        <div class="error-card">
            <div class="error-icon">🚫</div>
            <h1 class="error-title">访问被拒绝</h1>

            <?php if (isset($_SESSION['error_message'])): ?>
                <p class="error-message"><?php echo htmlspecialchars($_SESSION['error_message']); ?></p>
                <?php unset($_SESSION['error_message']); ?>
            <?php else: ?>
                <p class="error-message">您没有访问此页面的权限</p>
            <?php endif; ?>

            <div class="error-actions">
                <a href="javascript:history.back()" class="btn btn-secondary">返回上一页</a>
                <?php if (isset($_SESSION['user_id'])): ?>
                    <a href="user_home.php" class="btn btn-primary">返回主页</a>
                <?php else: ?>
                    <a href="index.php" class="btn btn-primary">返回登录</a>
                <?php endif; ?>
            </div>

            <div class="help-text">
                <p>如果您认为这是一个错误，请联系系统管理员</p>
            </div>
        </div>
    </div>

    <style>
    .error-container {
        min-height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
        background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
        padding: 20px;
    }

    .error-card {
        background: white;
        border-radius: 12px;
        padding: 40px;
        text-align: center;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
        max-width: 500px;
        width: 100%;
    }

    .error-icon {
        font-size: 64px;
        margin-bottom: 20px;
    }

    .error-title {
        color: var(--text-primary);
        font-size: 28px;
        font-weight: 600;
        margin-bottom: 20px;
    }

    .error-message {
        color: var(--text-secondary);
        font-size: 16px;
        line-height: 1.6;
        margin-bottom: 30px;
    }

    .error-actions {
        display: flex;
        gap: 15px;
        justify-content: center;
        margin-bottom: 30px;
        flex-wrap: wrap;
    }

    .help-text {
        color: var(--text-secondary);
        font-size: 14px;
        border-top: 1px solid var(--border-color);
        padding-top: 20px;
    }

    @media (max-width: 480px) {
        .error-card {
            padding: 30px 20px;
        }

        .error-actions {
            flex-direction: column;
        }

        .error-actions .btn {
            width: 100%;
        }
    }
    </style>
</body>
</html>